<%@ page import="activity.Event" %>
<!DOCTYPE html>
<html>
    <head>
        <meta name="layout" content="frontend">
        <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.min.js"></script>
        <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/localization/messages_zh_TW.js"></script>
    </head>
    <body>
        <div class="row">
            <g:form action="dataCheck">
                <div class="col-md-6">
                    <div class="panel panel-info">
                        <div class="panel-heading"><p class="text-center" style="font-size:40"><strong>${serial.name}</strong></p></div>
                        <ul class="list-group list-group-flush text-center">
                            <li class="list-group-item"><i class="icon-ok text-danger"></i>主辦單位：${serial.host}</li>
                            <li class="list-group-item"><i class="icon-ok text-danger"></i>承辦人：${serial.staff}</li>
                            <li class="list-group-item"><i class="icon-ok text-danger"></i>電話：${serial.tel}</li>
                            <li class="list-group-item"><i class="icon-ok text-danger"></i>Email：${serial.email}</li>
                        </ul>
                    </div><!--/panel-->
                    <g:each in="${events}" status="i" var="event">
                        <div id="detail${event.id}" name="detail" style="display:none" class="panel panel-info">
                            <div class="panel-heading"><p class="text-center" style="font-size:40"><strong>${event.name}</strong></p></div>
                            <ul class="list-group list-group-flush text-center">
                                <li class="list-group-item"><i class="icon-ok text-danger"></i>時間：${formatDate(format:"MM/dd HH:mm",date:event.dateStart)} ~ ${formatDate(format:" HH:mm",date:event.dateEnd)}</li>
                                <li class="list-group-item"><i class="icon-ok text-danger"></i>地點：${event.place}</li>
                                <li class="list-group-item"><i class="icon-ok text-danger"></i>名額：${fieldValue(bean: event, field: "registerQty")}/${fieldValue(bean: event, field: "capacityQty")}/${fieldValue(bean: event, field: "standbyQty")}</li>
                                <li class="list-group-item"><i class="icon-ok text-danger"></i>活動對象：${event.audience}</li>
                                <li class="list-group-item"><i class="icon-ok text-danger"></i>內容簡介：${event.intro}</li>
                                <g:if test="${event.files?.size() > 0}">
                                <li class="list-group-item"><i class="icon-ok text-danger"></i><g:link url="${createLinkTo(file:''+event.files)}">檔案下載</g:link></li>
                                    </g:if>
                            </ul>
                        </div><!--/panel-->
                    </g:each>
                    <table>
                        <thead>
                            <tr>
                                <th>場次確認</th>
                                <th>場次名稱</th>
                                <th>場次時間</th>
                                <th>詳細資訊</th>
                            </tr>
                        </thead>
                        <tbody>
                            <g:each in="${events}" status="i" var="eventInstance">
                                <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                                    <td><g:checkBox name="reg" value="${eventInstance.id}" checked="true"/></td>
                                    <td>${fieldValue(bean: eventInstance, field: "name")}</td>
                                    <td>${formatDate(format:"MM/dd HH:mm",date:eventInstance.dateStart)} ~ ${formatDate(format:" HH:mm",date:eventInstance.dateEnd)}</td>
                                    <td><a href="#" name="show" eventId="${eventInstance.id}">顯示</a></td>
                                </tr>
                            </g:each>
                        </tbody>
                    </table>
                </div><!--/col-->
                <div class="col-md-6">
                    <g:if test="${flash.message}">
                        <div style="color:red">${flash.message}</div>
                    </g:if>
                    <div class="form-group">
                        <label>姓名</label><span class="required-indicator">*</span>
                        <input name="name" class="form-control" placeholder="" required value="${reader?.name}">
                        <p class="help-block">請輸入全名</p>
                    </div>
                    <div class="form-group">
                        <label>性別</label><span class="required-indicator">*</span>
                        <g:select name="gender" class="form-control" from="${['男','女']}" value="${reader?.gender}"/>
                    </div>
                    <div class="form-group">
                        <label>生日</label><span class="required-indicator">*</span>
                        <input name="birth" class="form-control" placeholder="" required  value="${formatDate(format:"yyyy/M/d", date:reader?.birth)}">
                        <p class="help-block">格式：1964/2/9</p>
                        <!--<m:datePicker name="birth" precision="day" default="none" noSelection="['': '']" relativeYears="[-100..0]" class="form-control" value="${reader?.birth}"/>-->
                        <!--<p class="help-block">年／月／日</p>-->
                    </div>
                    <g:set var="column" value="${field.CID}" />
                    <g:if test="${column!='N'}">
                        <div class="form-group">
                            <label>身份證字號</label>
                            <g:if test="${column=='R'}">
                                <span class="required-indicator">*</span>
                                <input name="CID" class="form-control" placeholder="" required value="${reader?.CID}">
                            </g:if>
                            <g:else>
                                <input name="CID" class="form-control" placeholder="" value="${reader?.CID}">
                            </g:else>
                            <p class="help-block">輸入此欄位才可使用報名查詢功能</p>
                        </div>
                    </g:if>
                    <g:set var="column" value="${field.service}" />
                    <g:if test="${column!='N'}">
                        <div class="form-group">
                            <label>服務單位</label>
                            <g:if test="${column=='R'}"><span class="required-indicator">*</span>
                                <input name="service" class="form-control" placeholder="" required  value="${reader?.service}">
                            </g:if>
                            <g:else>
                                <input name="service" class="form-control" placeholder="" value="${reader?.service}">
                            </g:else>
                        </div>
                    </g:if>
                    <g:set var="column" value="${field.title}" />
                    <g:if test="${column!='N'}">
                        <div class="form-group">
                            <label>職稱</label>
                            <g:if test="${column=='R'}"><span class="required-indicator">*</span>
                                <input name="title" class="form-control" placeholder="" required value="${reader?.title}">
                            </g:if>
                            <g:else>
                                <input name="title" class="form-control" placeholder="" value="${reader?.title}">
                            </g:else>
                        </div>
                    </g:if>
                    <g:set var="column" value="${field.tel1}" />
                    <g:if test="${column!='N'}">
                        <div class="form-group">
                            <label>主要聯絡電話</label>
                            <g:if test="${column=='R'}"><span class="required-indicator">*</span>
                                <input name="tel1" class="form-control" placeholder="" required value="${reader?.tel1}">
                            </g:if>
                            <g:else>
                                <input name="tel1" class="form-control" placeholder="" value="${reader?.tel1}">
                            </g:else>
                        </div>
                    </g:if>
                    <g:set var="column" value="${field.tel2}" />
                    <g:if test="${column!='N'}">
                        <div class="form-group">
                            <label>次要聯絡電話</label>
                            <g:if test="${column=='R'}"><span class="required-indicator">*</span>
                                <input name="tel2" class="form-control" placeholder="" required value="${reader?.tel2}">
                            </g:if>
                            <g:else>
                                <input name="tel2" class="form-control" placeholder="" value="${reader?.tel2}">
                            </g:else>
                        </div>
                    </g:if>
                    <g:set var="column" value="${field.email1}" />
                    <g:if test="${column!='N'}">
                        <div class="form-group">
                            <label>主要Email</label>
                            <g:if test="${column=='R'}"><span class="required-indicator">*</span>
                                <input name="email1" class="form-control" placeholder="" required value="${reader?.email1}">
                            </g:if>
                            <g:else>
                                <input name="email1" class="form-control" placeholder="" value="${reader?.email1}">
                            </g:else>
                        </div>
                    </g:if>
                    <g:set var="column" value="${field.email2}" />
                    <g:if test="${column!='N'}">
                        <div class="form-group">
                            <label>次要Email</label>
                            <g:if test="${column=='R'}"><span class="required-indicator">*</span>
                                <input name="email2" class="form-control" placeholder="" required value="${reader?.email2}">
                            </g:if>
                            <g:else>
                                <input name="email2" class="form-control" placeholder="" value="${reader?.email2}">
                            </g:else>
                        </div>
                    </g:if>
                    <g:set var="column" value="${field.custom1}" />
                    <g:if test="${field.custom1Label}">
                        <div class="form-group">
                            <label>${field.custom1Label}</label>
                            <g:if test="${column=='R'}">
                                <span class="required-indicator">*</span>
                                <input name="custom1" class="form-control" placeholder="" required value="${reader?.custom1}">
                            </g:if>
                            <g:else>
                                <input name="custom1" class="form-control" placeholder="" value="${reader?.custom1}">
                            </g:else>
                        </div>
                    </g:if>
                    <g:set var="column" value="${field.custom2}" />
                    <g:if test="${field.custom2Label}">
                        <div class="form-group">
                            <label>${field.custom2Label}</label>
                            <g:if test="${column=='R'}">
                                <span class="required-indicator">*</span>
                                <input name="custom2" class="form-control" placeholder="" required value="${reader?.custom2}">
                            </g:if>
                            <g:else>
                                <input name="custom2" class="form-control" placeholder="" value="${reader?.custom2}">
                            </g:else>
                        </div>
                    </g:if>
                    <g:submitButton name="regEvents" value="我要報名" class="btn btn-primary" /><span id="error" style="color:red;display:none">　最少需選一場次！</span>
                </div><!--/col-->
            </g:form>
        </div><!--/row-->
    </body>
</html>